#ifndef _TASKTYPE_H_
#define _TASKTYPE_H_

#define USER_TASK_NUM 8

#define DEBUG_QUEUE_FALGS 0
#define DEBUG_BEGIN_END 0
#define DEBUG_CREATE_TAS0 0

typedef enum states_enum_name
{
	WAITING,
	READY,
	RUNNING
} states;

typedef enum schedule_enum_name
{
	FCFS,
	PRIO,
	SJF,
	RR

} sch_policy;

typedef struct myTCB_struct_name
{
	int tid;

	//状态
	states task_state;

	//栈指针
	unsigned long *stack_top, *stack_end;

	//函数入口地址
	void (*entry)(void);

	//剩余运行时间
	unsigned int runtime;

	//上次调度时间
	unsigned int leftTime;

	//优先级
	unsigned int priority;

	//总执行时间
	unsigned int exeTime;

	//到达时间
	unsigned int arrTime;

	void (*tskbody)(void);

	//链表
	struct myTCB_struct_name *next;
} myTCB;

typedef struct FIFOLIST_struct_name
{
	myTCB *start;
	myTCB *end;
} Q_LIST;

extern void myMain();

#define STACK_SIZE 0x2000
#define STACK_RESERVE 0x10
#define TASK_NUMBER (USER_TASK_NUM + 2)
#define initTskBody myMain

myTCB *idleTask;
myTCB *currentTask;
unsigned long BspContextBase[STACK_SIZE];
unsigned long *BspContext;

sch_policy sch_type;
myTCB * (*nextTsk)(void);
void (*enqueueTsk)(myTCB *tsk);
myTCB * (*dequeueTsk)(void);
void (*schedulerInit)(void);
void (*schedule)(void);
void (*tick_hook)(void);

#endif
